package com.lzb.newloan.view;


import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.Display;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;


import com.lzb.newloan.R;


public class MyProgressDialog extends ProgressDialog {
	private ImageView lading;
	private TextView lading_text;
	private String string;
	private AnimationDrawable rocketAnimation;
	private Display display;

	public MyProgressDialog(Context context, int theme) {
		super(context, theme);
	}

	public MyProgressDialog(Context context, String string) {
		super(context);
		this.string = string;
		WindowManager windowManager = (WindowManager) context
				.getSystemService(Context.WINDOW_SERVICE);
		display = windowManager.getDefaultDisplay();
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.my_progress_dialog);
//		RelativeLayout re = (RelativeLayout) findViewById(R.id.re);
		lading = (ImageView) findViewById(R.id.lading);
		lading_text = (TextView) findViewById(R.id.lading_text);
		rocketAnimation = (AnimationDrawable) lading.getBackground();
		lading_text.setText(string);
//		// 调整dialog背景大小
//		re.setLayoutParams(new FrameLayout.LayoutParams((int) (100), LinearLayout.LayoutParams.WRAP_CONTENT));

		this.setCanceledOnTouchOutside(false);
	}

	@Override
	public void show() {
		super.show();
		rocketAnimation.start();
	}

	@Override
	public void dismiss() {
		super.dismiss();
		rocketAnimation.stop();
	}
}
